﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PlaceHR.Processor.Processor
{
    public abstract class EngineBase : IEngine
    {
        public abstract string EngineName
        {
            get;
        }

        public virtual int Year
        {
            get;
            set;
        }

        public virtual int Month
        {
            get;
            set;
        }

        public virtual int Day
        {
            get;
            set;
        }

        public virtual bool ForceRecalculate
        {
            get;
            set;
        }

        public virtual ProcessorRecord Record
        {
            get;
            protected set;
        }

        private HRDBEntities _HRDBContext;
        public HRDBEntities HRDBContext
        {
            get
            {
                if (_HRDBContext == null)
                {
                    _HRDBContext = new HRDBEntities();
                }

                return _HRDBContext;
            }
        }

        public virtual void Run()
        {

        }

        public void LogEvent(string category, string message)
        {
            EventLog log = new EventLog
            {
                Category = category,
                Information = message,
                InsertDate = DateTime.Now
            };
            HRDBContext.EventLog.AddObject(log);
            HRDBContext.SaveChanges();
        }
    }
}
